<%@page pageEncoding="UTF-8" contentType="text/html; charset=utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<title>部门信息添加</title>
<base target="_self"/>
	<script type="text/javascript"
		src="<%=request.getContextPath()%>/dwr/interface/BmxxService.js"></script>
	<script type="text/javascript"
		src="<%=request.getContextPath()%>/dwr/engine.js"></script>
	<script type="text/javascript"
		src="<%=request.getContextPath()%>/dwr/util.js"></script>
<jsp:include page="../common/init.jsp"></jsp:include>
</head>
<script type="text/javascript">
var sameBmxx = false;
//验证部门名称是否重复
function checkBmmc1(){
   var checkValue=document.getElementById("appsysBmxx.bmmc").value;
    DWREngine.setAsync(false);
   BmxxService.checkBmmc(checkValue,callBack1);
    DWREngine.setAsync(true);
}
function callBack1(data){
  if(data==true){ 
     sameBmxx = true;
   }
}
//验证部门名称
function validateBmmc(ajaxFlag)
{
	var checkId="appsysBmxx.bmmc";
	var checkValue=document.getElementById("appsysBmxx.bmmc").value;
	var errorDivId="bmmcDiv";
	var errorImgId="bmmcImg";
	if(checkNullValue(checkValue))
	{
		showMenuDelegate(checkId,errorDivId,errorImgId,"部门名称不能为空!");
		return false;
	}
	else if (ajaxFlag=='b'){
	    checkBmmc1();
		if(sameBmxx)
		{    
			showMenuDelegate(checkId,errorDivId,errorImgId,"部门名称已被用,请重新填写!");
			return false;
		}
		else
		{
			return true;
		}
	}
	else
	{
		hiddenErrorImg(errorImgId);
		return true;
	}
}
//选择上级部门
function selBmxx()
{
	var action="<%=request.getContextPath() %>/qxgl/selBmxx.do?tempid=" + Math.random()
	win = window.showModalDialog(action,null,'dialogHeight=450px;dialogWidth=310px;status=no;scroll=no;help=no');
    callback(win);
}
function callback(rValue){
	if(rValue!=null)
	{
		bmxx=rValue;
		document.getElementById("sjbmbh").value=bmxx[0];
		document.getElementById("sjbmmc").value=bmxx[1];
	}
}
//提交
function doSubmit()
{
	var bmmcFlag=validateBmmc('b');	
	 if(bmmcFlag)
	 {
		document.forms[0].action="createBmxx.do";
		document.forms[0].submit();
	 }
	 else
	{
		return false;
	}
}
//页面关闭
function winClose()
{
	window.returnValue = "ok";
	window.close();
}
//表单reset
function formReset()
{
	document.forms[0].reset();
}
//生成功能按钮	
mpmenu1=new mMenu('','winClose()','script','<%=request.getContextPath() %>/images/img_ht_wz_44.gif','62','24','0','100','2');
mpmenu2=new mMenu('','#','self','<%=request.getContextPath() %>/images/img_ht_wz_38.gif','62','24','0','20','0');
mpmenu3=new mMenu('','#','self','<%=request.getContextPath() %>/images/img_ht_wz_42.gif','62','24','0','20','0');
</script>
<body onload="showMessage()">
<s:form action="">
<table cellspacing="0" cellpadding="0" class="main_tab1" onclick="javascript: mouseClick('errorDivCreateWzbm');">
    <tr>
        <td rowspan="4" class="main_tab1_td8">&nbsp;</td>
        <td class="main_tab1_td1"><img src="<%=request.getContextPath() %>/images/img_ht_wz_28.gif" alt="left" /></td>
        <td class="main_tab1_td2">
		<div id="location">部门信息添加</div>
		<div id="funbut">
			<SCRIPT>document.write(mwritetodocument());</SCRIPT>
		</div>
		</td>
        <td class="main_tab1_td1"><img src="<%=request.getContextPath() %>/images/img_ht_wz_32.gif" alt="right" /></td>
    </tr>
    <tr>
        <td colspan="3" class="main_tab1_td3">
		<div id="mainbg">
		<div class="jiange10"></div>
		<table width="100%" border="0" cellspacing="0" cellpadding="0" class="main_tab3">
				<tr valign="bottom" height="30">
					<td height="25" colspan="2" align="left" valign="bottom" class="r_tab_c_4">
						<div id="infoMessage"></div>
					</td>
				</tr>
				<tr valign="bottom" align="center" height="30" >
					<th align="right">
						部门名称：
					</th>
					<td align="left" >
					<s:textfield id="appsysBmxx.bmmc" name="appsysBmxx.bmmc" size="25" maxLength="50"
						theme="simple" onclick="javascript: mouseClick('bmmcDiv')"
								onfocus="this.style.borderColor='#68A6F5'"  onblur="validateBmmc('a');" cssClass="inp_02">
					</s:textfield>
						 &nbsp;
				<img src="" id="bmmcImg" style="display:none;"/>
				<div id="bmmcDiv" style="background:#008080;display:none;cursor:default">
				</div>
					</td>
				</tr>
				<tr valign="bottom" height="30">
					<th align="right">
						上级部门：
					</th>
					<td >
					<s:hidden name="appsysBmxx.sjbmbh" id="sjbmbh" ></s:hidden>
					<s:textfield id="sjbmmc"  name="sjbmmc"  theme="simple" size="25" maxLength="50" cssClass="inp_02" disabled="true"/>
					&nbsp;
					<a href="javascript:void(0)" onfocus="this.blur()" >
					<img src="<%=request.getContextPath() %>/images/img_ht_wz_82.gif" border="0"  onclick="selBmxx();" ></a>
					</td>
				</tr>
				<tr valign="bottom" height="30">
					<th align="right">
						排序号：
					</th>
					<td  align="left" valign="bottom">
						<s:textfield id="appsysBmxx.pxh" name="appsysBmxx.pxh" value="1" size="2"
							maxLength="2" theme="simple" onfocus="this.style.borderColor='#68A6F5'" cssClass="inp_02">
					</s:textfield>
						 &nbsp;
				<img src="" id="pxhImg" style="display:none;"/>
				<div id="pxhDiv" style="background:#008080;display:none;cursor:default"/>
					</td>
				</tr>
				<tr valign="bottom" >
					<th valign="center" align="right">
						部门描述：
					</th>
					<td>
						<textarea id="bmms" name="appsysBmxx.bmms" cols="35" rows="6"></textarea>
						 &nbsp;
				<img src="" id="bmmsImg" style="display:none;"/>
				<div id="bmmsDiv" style="background:#008080;display:none;cursor:default"/>
					</td>
				</tr>
			</table>
<div class="butk">
<div class="btn_01">
<a href="#" onclick="doSubmit()">保&nbsp;存</a>
</div>
<div class="btn_01">
<a href="#" onclick="formReset()">清&nbsp;除</a>
</div>
</div>
</div>
</td>
    </tr>
    <tr>
        <td class="main_tab1_td4"><img src="<%=request.getContextPath() %>/images/img_ht_wz_65.gif" alt="left" /></td>
        <td class="main_tab1_td5"></td>
        <td class="main_tab1_td4"><img src="<%=request.getContextPath() %>/images/img_ht_wz_67.gif" alt="right" /></td>
    </tr>
    <tr>
        <td colspan="3" class="main_tab1_td7">&nbsp;</td>
    </tr>
</table>
</s:form>
</body>
</html>
